home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / emacs_src_18_58.lha / emacs-18.58 / src / emacs.c < prev    next >
C/C++ Source or Header  |  1992-08-08  |  18KB  |  759 lines

  1. /* Fully extensible Emacs, running on Unix, intended for GNU.
  2.    Copyright (C) 1985, 1986, 1987, 1990 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #include <signal.h>
  22. #include <errno.h>
  23.  
  24. #include "config.h"
  25. #ifdef NULL
  26. #undef NULL
  27. #endif
  28. #include "lisp.h"
  29. #undef NULL
  30. #include "commands.h"
  31.  
  32. /* Get FIONREAD, if it is available,
  33.    just to help decide whether SIGIO should be defined.  */
  34. #ifdef USG
  35. #include <termio.h>
  36. #include <fcntl.h>
  37. #else /* not USG */
  38. #ifndef VMS
  39. #include <sys/ioctl.h>
  40. #endif /* not VMS */
  41. #endif /* not USG */
  42.  
  43. /* Allow m- file to inhibit use of FIONREAD.  */
  44. #ifdef BROKEN_FIONREAD
  45. #undef FIONREAD
  46. #endif
  47.  
  48. /* We are unable to use interrupts if FIONREAD is not available,
  49.    so flush SIGIO so we won't try. */
  50. #ifndef FIONREAD
  51. #ifdef SIGIO
  52. #undef SIGIO
  53. #endif
  54. #endif
  55.  
  56. #include <stdio.h>
  57. #include <sys/types.h>
  58. #include <sys/file.h>
  59.  
  60. #ifdef VMS
  61. #include <ssdef.h>
  62. #endif
  63.  
  64. #ifdef USG5
  65. #include <fcntl.h>
  66. #endif
  67.  
  68. #ifdef BSD
  69. #include <sys/ioctl.h>
  70. #endif
  71.  
  72. #ifdef APOLLO
  73. #ifndef APOLLO_SR10
  74. #include <default_acl.h>
  75. #endif
  76. #endif
  77.  
  78. #ifdef AMIGA_DUMP
  79. #define HAVE_SHM        /* Simplifies the ifdefs */
  80. #endif
  81.  
  82. #ifndef O_RDWR
  83. #define O_RDWR 2
  84. #endif
  85.  
  86. #define PRIO_PROCESS 0
  87.  
  88. /* Command line args from shell, as list of strings */
  89. Lisp_Object Vcommand_line_args;
  90.  
  91. /* Hook run by `kill-emacs' before it does really anything.  */
  92. Lisp_Object Vkill_emacs_hook;
  93.  
  94. /* Set nonzero after Emacs has started up the first time.
  95.   Prevents reinitialization of the Lisp world and keymaps
  96.   on subsequent starts.  */
  97. int initialized;
  98.  
  99. /* Variable whose value is symbol giving operating system type */
  100. Lisp_Object Vsystem_type;
  101.   
  102. /* If non-zero, emacs should not attempt to use an window-specific code,
  103.    but instead should use the virtual terminal under which it was started */
  104. int inhibit_window_system;
  105.  
  106. #ifdef HAVE_X_WINDOWS
  107. /* If -d option is used, this variable points to the name of
  108.    the display to use.  */
  109. char *alternate_display;
  110. char **xargv;
  111. int xargc;
  112. #endif /* HAVE_X_WINDOWS */
  113.  
  114. #ifdef USG_SHARED_LIBRARIES
  115. /* If nonzero, this is the place to put the end of the writable segment
  116.    at startup.  */
  117.  
  118. unsigned int bss_end = 0;
  119. #endif
  120.  
  121. /* Nonzero means running Emacs without interactive terminal.  */
  122.  
  123. int noninteractive;
  124.  
  125. /* Value of Lisp variable `noninteractive'.
  126.    Normally same as C variable `noninteractive'
  127.    but nothing terrible happens if user sets this one.  */
  128.  
  129. int noninteractive1;
  130.  
  131. /* Signal code for the fatal signal that was received */
  132. int fatal_error_code;
  133.  
  134. /* Nonzero if handling a fatal error already */
  135. int fatal_error_in_progress;
  136.  
  137. /* Handle bus errors, illegal instruction, etc. */
  138. fatal_error_signal (sig)
  139.      int sig;
  140. {
  141. #ifdef BSD
  142.   int tpgrp;
  143. #endif /* BSD */
  144.  
  145.   fatal_error_code = sig;
  146.   signal (sig, SIG_DFL);
  147.  
  148.   /* If fatal error occurs in code below, avoid infinite recursion.  */
  149.   if (fatal_error_in_progress)
  150.     kill (getpid (), fatal_error_code);
  151.  
  152.   fatal_error_in_progress = 1;
  153.  
  154.   /* If we are controlling the terminal, reset terminal modes */
  155. #ifdef BSD
  156.   if (ioctl(0, TIOCGPGRP, &tpgrp) == 0
  157.       && tpgrp == getpgrp (0))
  158. #endif /* BSD */
  159.     {
  160.       reset_sys_modes ();
  161.       if (sig != SIGTERM)
  162.     fprintf (stderr, "Fatal error (%d).", sig);
  163.     }
  164.  
  165.   /* Clean up */
  166. #ifdef subprocesses
  167.   kill_buffer_processes (Qnil);
  168. #endif
  169.   Fdo_auto_save (Qt);
  170.  
  171. #ifdef CLASH_DETECTION
  172.   unlock_all_files ();
  173. #endif /* CLASH_DETECTION */
  174.  
  175. #ifdef VMS
  176.   kill_vms_processes ();
  177.   LIB$STOP (SS$_ABORT);
  178. #else
  179.   /* Signal the same code; this time it will really be fatal.  */
  180.   kill (getpid (), fatal_error_code);
  181. #endif /* not VMS */
  182. }
  183.  
  184. /* Code for dealing with Lisp access to the Unix command line */
  185.  
  186. static
  187. init_cmdargs (argc, argv, skip_args)
  188.      int argc;
  189.      char **argv;
  190.      int skip_args;
  191. {
  192.   register int i;
  193.  
  194.   Vcommand_line_args = Qnil;
  195.  
  196.   for (i = argc - 1; i >= 0; i--)
  197.     {
  198.       if (i == 0 || i > skip_args)
  199.     Vcommand_line_args
  200.       = Fcons (build_string (argv[i]), Vcommand_line_args);
  201.     }
  202. }
  203.  
  204. #ifdef VMS
  205. #ifdef LINK_CRTL_SHARE
  206. #ifdef SHAREABLE_LIB_BUG
  207. #ifdef __GNUC__
  208. #define    environ $$PsectAttributes_NOSHR$$environ
  209. extern char **environ;
  210. #else
  211. extern noshare char **environ;
  212. #endif
  213. #endif /* SHAREABLE_LIB_BUG */
  214. #endif /* LINK_CRTL_SHARE */
  215. #endif /* VMS */
  216.  
  217. /* ARGSUSED */
  218. main (argc, argv, envp)
  219.      int argc;
  220.      char **argv;
  221.      char **envp;
  222. {
  223.   int skip_args = 0;
  224.   extern int errno;
  225.   extern void malloc_warning ();
  226.  
  227. /* Map in shared memory, if we are using that.  */
  228. #ifdef HAVE_SHM
  229.   if (argc > 1 && !strcmp (argv[1], "-nl"))
  230.     {
  231.       map_in_data (0);
  232.       /* The shared memory was just restored, which clobbered this.  */
  233.       skip_args = 1;
  234.     }
  235.   else
  236.     {
  237.       map_in_data (1);
  238.       /* The shared memory was just restored, which clobbered this.  */
  239.       skip_args = 0;
  240.     }
  241. #endif
  242.  
  243. #ifdef VMS
  244.   /* If -map specified, map the data file in */
  245.   if (argc > 2 && ! strcmp (argv[1], "-map"))
  246.     {
  247.       skip_args = 2;
  248.       mapin_data (argv[2]);
  249.     }
  250.  
  251. #ifdef LINK_CRTL_SHARE
  252. #ifdef SHAREABLE_LIB_BUG
  253.   /* Bletcherous shared libraries! */
  254.   if (!stdin)
  255.     stdin = fdopen (0, "r");
  256.   if (!stdout)
  257.     stdout = fdopen (1, "w");
  258.   if (!stderr)
  259.     stderr = fdopen (2, "w");
  260.   if (!environ)
  261.     environ = envp;
  262. #endif /* SHAREABLE_LIB_BUG */
  263. #endif /* LINK_CRTL_SHARE */
  264. #endif /* VMS */
  265.  
  266. #ifdef USG_SHARED_LIBRARIES
  267.   if (bss_end)
  268.     brk (bss_end);
  269. #endif
  270.  
  271.   clearerr (stdin);
  272.  
  273. #ifdef APOLLO
  274. #ifndef APOLLO_SR10
  275.   /* If USE_DOMAIN_ACLS environment variable exists,
  276.      use ACLs rather than UNIX modes. */
  277.   if (egetenv ("USE_DOMAIN_ACLS"))
  278.     default_acl (USE_DEFACL);
  279. #endif
  280. #endif /* APOLLO */
  281.  
  282. #ifndef SYSTEM_MALLOC
  283.   /* Arrange for warnings when nearly out of space.  */
  284.   malloc_init (0, malloc_warning);
  285. #endif
  286.  
  287. #ifdef HIGHPRI
  288.   setpriority (PRIO_PROCESS, getpid (), HIGHPRI);
  289.   setuid (getuid ());
  290. #endif HIGHPRI
  291.  
  292.   inhibit_window_system = 0;
  293.  
  294. #ifdef HAVE_X_WINDOWS
  295.   xargv = argv;
  296.   xargc = argc;
  297. #endif
  298.  
  299. #ifndef AMIGA
  300. /* Handle the -t switch, which specifies filename to use as terminal */
  301.   if (skip_args + 2 < argc && !strcmp (argv[skip_args + 1], "-t"))
  302.     {
  303.       skip_args += 2;
  304.       close (0);
  305.       close (1);
  306.       open (argv[skip_args], O_RDWR, 2 );
  307.       dup (0);
  308.       fprintf (stderr, "Using %s\n", argv[skip_args]);
  309. #ifdef HAVE_X_WINDOWS
  310.       inhibit_window_system = 1;    /* -t => -nw */
  311. #endif
  312.     }
  313. #endif
  314. #ifdef HAVE_X_WINDOWS
  315. /* Handle the -d switch, which means use a different display for X */
  316.   if (skip_args + 2 < argc && (!strcmp (argv[skip_args + 1], "-d") ||
  317.                    !strcmp (argv[skip_args + 1], "-display")))
  318.     {
  319.       skip_args += 2;
  320.       alternate_display = argv[skip_args];
  321.     } 
  322.   else
  323.     alternate_display = 0;
  324. #endif    /* HAVE_X_WINDOWS */
  325.  
  326.   if (skip_args + 1 < argc
  327.       && (!strcmp (argv[skip_args + 1], "-nw")))
  328.     {
  329.       skip_args += 1;
  330.       inhibit_window_system = 1;
  331.     }
  332.  
  333. /* Handle the -batch switch, which means don't do interactive display.  */
  334.   noninteractive = 0;
  335.   if (skip_args + 1 < argc && !strcmp (argv[skip_args + 1], "-batch"))
  336.     {
  337.       skip_args += 1;
  338.       noninteractive = 1;
  339.     }
  340.  
  341. #ifdef POSIX_SIGNALS
  342.   init_signals ();
  343. #endif
  344.  
  345. #ifdef HAVE_TZSET
  346.   /* Reinitialize the time zone if it was initialized before dumping Emacs.  */
  347.   if (initialized)
  348.     tzset ();
  349. #endif
  350.  
  351.   if (
  352. #ifndef CANNOT_DUMP
  353.       ! noninteractive || initialized
  354. #else
  355.       1
  356. #endif
  357.       )
  358.     {
  359.       /* Don't catch these signals in batch mode if not initialized.
  360.      On some machines, this sets static data that would make
  361.      signal fail to work right when the dumped Emacs is run.  */
  362.       signal (SIGHUP, fatal_error_signal);
  363.       signal (SIGQUIT, fatal_error_signal);
  364.       signal (SIGILL, fatal_error_signal);
  365.       signal (SIGTRAP, fatal_error_signal);
  366.       signal (SIGIOT, fatal_error_signal);
  367. #ifdef SIGEMT
  368.       signal (SIGEMT, fatal_error_signal);
  369. #endif
  370.       signal (SIGFPE, fatal_error_signal);
  371.       signal (SIGBUS, fatal_error_signal);
  372.       signal (SIGSEGV, fatal_error_signal);
  373.       signal (SIGSYS, fatal_error_signal);
  374.       signal (SIGTERM, fatal_error_signal);
  375. #ifdef SIGXCPU
  376.       signal (SIGXCPU, fatal_error_signal);
  377. #endif
  378. #ifdef SIGXFSZ
  379.       signal (SIGXFSZ, fatal_error_signal);
  380. #endif SIGXFSZ
  381.  
  382. #ifdef AIX
  383.       /* This used to run fatal_error_signal,
  384.      but it isn't fatal.  There's nothing Emacs can usefully do.
  385.      Might as well let the system kill us if it insists.  */
  386.       signal (SIGDANGER, SIG_IGN);
  387.       signal (20, fatal_error_signal);
  388.       signal (21, fatal_error_signal);
  389.       signal (22, fatal_error_signal);
  390.       signal (23, fatal_error_signal);
  391.       signal (24, fatal_error_signal);
  392. #ifdef SIGIO
  393.       signal (SIGAIO, fatal_error_signal);
  394.       signal (SIGPTY, fatal_error_signal);
  395. #endif
  396. #ifdef SIGURG
  397.       /* Note that SIGIOINT is the same as SIGIO on some machines,
  398.      and the same as SIGURG on others.  It seems ore reliable to use the
  399.      name with a uniform meaning.  */
  400.       signal (SIGURG, fatal_error_signal);
  401. #endif
  402.       signal (SIGGRANT, fatal_error_signal);
  403.       signal (SIGRETRACT, fatal_error_signal);
  404.       signal (SIGSOUND, fatal_error_signal);
  405.       signal (SIGMSG, fatal_error_signal);
  406. #endif /* AIX */
  407.     }
  408.  
  409.   noninteractive1 = noninteractive;
  410.  
  411. /* Perform basic initializations (not merely interning symbols) */
  412.  
  413.   if (!initialized)
  414.     {
  415.       init_alloc_once ();
  416.       init_obarray ();
  417.       init_eval_once ();
  418.       init_syntax_once ();    /* Create standard syntax table.  */
  419.               /* Must be done before init_buffer */
  420.       init_buffer_once ();    /* Create buffer table and some buffers */
  421.       init_minibuf_once ();    /* Create list of minibuffers */
  422.                   /* Must precede init_window_once */
  423.       init_window_once ();    /* Init the window system */
  424.     }
  425.  
  426.   init_alloc ();
  427. #ifdef MAINTAIN_ENVIRONMENT
  428.   init_environ ();
  429. #endif
  430.   init_eval ();
  431.   init_data ();
  432.   init_read ();
  433.  
  434.   init_cmdargs (argc, argv, skip_args);    /* Create list Vcommand_line_args */
  435.   init_buffer ();    /* Init default directory of main buffer */
  436.   if (!noninteractive)
  437.     {
  438. #ifdef VMS
  439.       init_vms_input ();/* init_display calls get_screen_size, that needs this */
  440. #endif /* VMS */
  441.       init_display ();    /* Determine terminal type.  init_sys_modes uses results */
  442.     }
  443.   init_keyboard ();    /* This too must precede init_sys_modes */
  444.   init_callproc ();    /* And this too. */
  445.   init_sys_modes ();    /* Init system terminal modes (RAW or CBREAK, etc.) */
  446.   init_xdisp ();
  447.   init_macros ();
  448.   init_editfns ();
  449. #ifdef VMS
  450.   init_vmsfns ();
  451. #endif /* VMS */
  452. #ifdef subprocesses
  453.   init_process ();
  454. #endif /* subprocesses */
  455.  
  456. /* Intern the names of all standard functions and variables; define standard keys */
  457.  
  458.   if (!initialized)
  459.     {
  460.       /* The basic levels of Lisp must come first */
  461.       /* And data must come first of all
  462.      for the sake of symbols like error-message */
  463.       syms_of_data ();
  464.       syms_of_alloc ();
  465. #ifdef MAINTAIN_ENVIRONMENT
  466.       syms_of_environ ();
  467. #endif MAINTAIN_ENVIRONMENT
  468.       syms_of_read ();
  469.       syms_of_print ();
  470.       syms_of_eval ();
  471.       syms_of_fns ();
  472.  
  473.       syms_of_abbrev ();
  474.       syms_of_buffer ();
  475.       syms_of_bytecode ();
  476.       syms_of_callint ();
  477.       syms_of_casefiddle ();
  478.       syms_of_callproc ();
  479.       syms_of_cmds ();
  480. #ifndef NO_DIR_LIBRARY
  481.       syms_of_dired ();
  482. #endif /* not NO_DIR_LIBRARY */
  483.       syms_of_display ();
  484.       syms_of_doc ();
  485.       syms_of_editfns ();
  486.       syms_of_emacs ();
  487.       syms_of_fileio ();
  488. #ifdef CLASH_DETECTION
  489.       syms_of_filelock ();
  490. #endif /* CLASH_DETECTION */
  491.       syms_of_indent ();
  492.       syms_of_keyboard ();
  493.       syms_of_keymap ();
  494.       syms_of_macros ();
  495.       syms_of_marker ();
  496.       syms_of_minibuf ();
  497.       syms_of_mocklisp ();
  498. #ifdef subprocesses
  499.       syms_of_process ();
  500. #endif /* subprocesses */
  501.       syms_of_search ();
  502.       syms_of_syntax ();
  503.       syms_of_undo ();
  504.       syms_of_window ();
  505.       syms_of_xdisp ();
  506. #ifdef HAVE_X_WINDOWS
  507.       syms_of_xfns ();
  508. #ifdef HAVE_X_MENU
  509.       syms_of_xmenu ();
  510. #endif /* HAVE_X_MENU */
  511. #endif /* HAVE_X_WINDOWS */
  512.  
  513. #ifdef SYMS_SYSTEM
  514.       SYMS_SYSTEM;
  515. #endif
  516.  
  517. #ifdef SYMS_MACHINE
  518.       SYMS_MACHINE;
  519. #endif
  520.  
  521.       keys_of_casefiddle ();
  522.       keys_of_cmds ();
  523.       keys_of_buffer ();
  524.       keys_of_keyboard ();
  525.       keys_of_keymap ();
  526.       keys_of_macros ();
  527.       keys_of_minibuf ();
  528.       keys_of_window ();
  529.     }
  530.  
  531.   if (!initialized)
  532.     {
  533.       /* Handle -l loadup-and-dump, args passed by Makefile. */
  534.       if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l"))
  535.     Vtop_level = Fcons (intern ("load"),
  536.                 Fcons (build_string (argv[2 + skip_args]), Qnil));
  537. #ifdef CANNOT_DUMP
  538.       /* Unless next switch is -nl, load "loadup.el" first thing.  */
  539.       if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl")))
  540.     Vtop_level = Fcons (intern ("load"),
  541.                 Fcons (build_string ("loadup.el"), Qnil));
  542. #endif /* CANNOT_DUMP */
  543.     }
  544.  
  545.   initialized = 1;
  546.  
  547.   /* Enter editor command loop.  This never returns.  */
  548.   Frecursive_edit ();
  549.   /* NOTREACHED */
  550. }
  551.  
  552. DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
  553.   "Exit the Emacs job and kill it.  ARG means no query.\n\
  554. If emacs is running noninteractively and ARG is an integer,\n\
  555. return ARG as the exit program code.")
  556.   (arg)
  557.      Lisp_Object arg;
  558. {
  559.   Lisp_Object answer;
  560.   int i;
  561.   struct gcpro gcpro1;
  562.  
  563.   GCPRO1 (arg);
  564.  
  565.   if (!EQ (Vkill_emacs_hook, Qnil))
  566.     call0 (Vkill_emacs_hook);
  567.  
  568.   if (feof (stdin))
  569.     arg = Qt;
  570.  
  571. #ifdef subprocesses
  572.   kill_buffer_processes (Qnil);
  573. #endif /* subprocesses */
  574.  
  575. #ifdef VMS
  576.   kill_vms_processes ();
  577. #endif /* VMS */
  578.  
  579.   Fdo_auto_save (Qt);
  580.  
  581. #ifdef CLASH_DETECTION
  582.   unlock_all_files ();
  583. #endif /* CLASH_DETECTION */
  584.  
  585.   fflush (stdout);
  586.   reset_sys_modes ();
  587.   UNGCPRO;
  588.  
  589. /* Is it really necessary to do this deassign
  590.    when we are going to exit anyway?  */
  591. /* #ifdef VMS
  592.   stop_vms_input ();
  593.  #endif  */
  594.   stuff_buffered_input (arg);
  595. #ifdef SIGIO
  596.   /* There is a tendency for a SIGIO signal to arrive within exit,
  597.      and cause a SIGHUP because the input descriptor is already closed.  */
  598.   unrequest_sigio ();
  599.   signal (SIGIO, SIG_IGN);
  600. #endif
  601.   exit ((XTYPE (arg) == Lisp_Int) ? XINT (arg)
  602. #ifdef VMS
  603.     : 1
  604. #else
  605.     : 0
  606. #endif
  607.     );
  608.   /* NOTREACHED */
  609. }
  610.  
  611. #ifndef CANNOT_DUMP
  612. /* Nothing like this can be implemented on an Apollo.
  613.    What a loss!  */
  614.  
  615. #ifdef HAVE_SHM
  616.  
  617. DEFUN ("dump-emacs-data", Fdump_emacs_data, Sdump_emacs_data, 1, 1, 0,
  618.   "Dump current state of Emacs into data file FILENAME.\n\
  619. This function exists on systems that use HAVE_SHM.")
  620.   (intoname)
  621.      Lisp_Object intoname;
  622. {
  623.   extern int my_edata;
  624.   Lisp_Object tem;
  625.   extern void malloc_warning ();
  626.  
  627.   CHECK_STRING (intoname, 0);
  628.   intoname = Fexpand_file_name (intoname, Qnil);
  629.  
  630.   tem = Vpurify_flag;
  631.   Vpurify_flag = Qnil;
  632.  
  633.   fflush (stdout);
  634.   /* Tell malloc where start of impure now is */
  635.   /* Also arrange for warnings when nearly out of space.  */
  636. #ifndef SYSTEM_MALLOC
  637.   malloc_init (&my_edata, malloc_warning);
  638. #endif
  639.   map_out_data (XSTRING (intoname)->data);
  640.  
  641.   Vpurify_flag = tem;
  642.  
  643.   return Qnil;
  644. }
  645.  
  646. #else /* not HAVE_SHM */
  647.  
  648. DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0,
  649.   "Dump current state of Emacs into executable file FILENAME.\n\
  650. Take symbols from SYMFILE (presumably the file you executed to run Emacs).")
  651.   (intoname, symname)
  652.      Lisp_Object intoname, symname;
  653. {
  654.   extern int my_edata;
  655.   Lisp_Object tem;
  656.   extern void malloc_warning ();
  657.  
  658.   CHECK_STRING (intoname, 0);
  659.   intoname = Fexpand_file_name (intoname, Qnil);
  660.   if (!EQ (symname, Qnil))
  661.     {
  662.       CHECK_STRING (symname, 0);
  663.       if (XSTRING (symname)->size)
  664.     symname = Fexpand_file_name (symname, Qnil);
  665.     }
  666.  
  667.   tem = Vpurify_flag;
  668.   Vpurify_flag = Qnil;
  669.  
  670.   fflush (stdout);
  671. #ifdef VMS
  672.   mapout_data (XSTRING (intoname)->data);
  673. #else
  674.   /* Tell malloc where start of impure now is */
  675.   /* Also arrange for warnings when nearly out of space.  */
  676. #ifndef SYSTEM_MALLOC
  677.   malloc_init (&my_edata, malloc_warning);
  678. #endif
  679.   unexec (XSTRING (intoname)->data,
  680.       !EQ (symname, Qnil) ? XSTRING (symname)->data : 0, &my_edata, 0, 0);
  681. #endif /* not VMS */
  682.  
  683.   Vpurify_flag = tem;
  684.  
  685.   return Qnil;
  686. }
  687.  
  688. #endif /* not HAVE_SHM */
  689.  
  690. #endif /* not CANNOT_DUMP */
  691.  
  692. #ifdef VMS
  693. #define SEPCHAR ','
  694. #else
  695. #ifdef AMIGA            /* Can't use : on Amiga */
  696. #define SEPCHAR ','
  697. #else
  698. #define SEPCHAR ':'
  699. #endif
  700. #endif
  701.  
  702. Lisp_Object
  703. decode_env_path (evarname, defalt)
  704.      char *evarname, *defalt;
  705. {
  706.   register char *path, *p;
  707.   extern char *index ();
  708.  
  709.   Lisp_Object lpath;
  710.  
  711.   if (evarname != 0)
  712.     path = (char *) egetenv (evarname);
  713.   else
  714.     path = 0;
  715.   if (!path)
  716.     path = defalt;
  717.   lpath = Qnil;
  718.   while (1)
  719.     {
  720.       p = index (path, SEPCHAR);
  721.       if (!p) p = path + strlen (path);
  722.       lpath = Fcons (p - path ? make_string (path, p - path) : Qnil,
  723.              lpath);
  724.       if (*p)
  725.     path = p + 1;
  726.       else
  727.     break;
  728.     }
  729.   return Fnreverse (lpath);
  730. }
  731.  
  732. syms_of_emacs ()
  733. {
  734. #ifndef CANNOT_DUMP
  735. #ifdef HAVE_SHM
  736.   defsubr (&Sdump_emacs_data);
  737. #else
  738.   defsubr (&Sdump_emacs);
  739. #endif
  740. #endif /* not CANNOT_DUMP */
  741.  
  742.   defsubr (&Skill_emacs);
  743.  
  744.   DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
  745.     "Args passed by shell to Emacs, as a list of strings.");
  746.  
  747.   DEFVAR_LISP ("system-type", &Vsystem_type,
  748.     "Symbol indicating type of operating system you are using.");
  749.   Vsystem_type = intern (SYSTEM_TYPE);
  750.  
  751.   DEFVAR_BOOL ("noninteractive", &noninteractive1,
  752.     "Non-nil means Emacs is running without interactive terminal.");
  753.  
  754.   Vkill_emacs_hook = Qnil;
  755.  
  756.   DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook,
  757.     "Function called, if non-nil, whenever kill-emacs is called.");
  758. }
  759.